home *** CD-ROM | disk | FTP | other *** search
/ One Click 21 (Special) / OC021.iso / Juegos / King of Skeleton / King of Skeleton.swf / scripts / __Packages / BackgroundMask.as < prev    next >
Encoding:
Text File  |  2006-02-02  |  2.7 KB  |  107 lines

  1. class BackgroundMask extends MovieClip
  2. {
  3.    var rad;
  4.    var l;
  5.    var r;
  6.    var sx;
  7.    var sy;
  8.    var col;
  9.    var mask;
  10.    var lo;
  11.    var ro;
  12.    var ft = 1;
  13.    static var cd = 2.8;
  14.    static var bf = new flash.filters.BlurFilter(2,2,1);
  15.    static var flashOn = {aa:100,ab:0,ra:100,rb:3,ga:100,gb:3,ba:100,bb:3};
  16.    static var flashOff = {aa:100,ab:0,ra:100,rb:0,ga:100,gb:0,ba:100,bb:0};
  17.    function BackgroundMask()
  18.    {
  19.       super();
  20.       if(!_root.brdcst)
  21.       {
  22.          _root.brdcst = {};
  23.          AsBroadcaster.initialize(_root.brdcst);
  24.       }
  25.       _root.brdcst.addListener(this);
  26.       this.rad = Math.sqrt(this.l._x * this.l._x + this.l._y * this.l._y);
  27.       this.l._visible = false;
  28.       this.r._visible = false;
  29.       this.sx = this._x;
  30.       this.sy = this._y;
  31.       this.cacheAsBitmap = true;
  32.       this.col = new Color(this);
  33.    }
  34.    function drawMask()
  35.    {
  36.       this.mask.clear();
  37.       this.mask.beginFill(0,100);
  38.       var _loc2_ = {x:0,y:0};
  39.       this.lo.localToGlobal(_loc2_);
  40.       var _loc3_ = Math.floor(_loc2_.x);
  41.       this.mask.moveTo(_loc3_,Stage.height);
  42.       this.mask.lineTo(_loc3_,_loc2_.y);
  43.       _loc2_ = {x:0,y:0};
  44.       this.l.localToGlobal(_loc2_);
  45.       var _loc5_ = _loc2_.y;
  46.       this.mask.lineTo(_loc2_.x,_loc2_.y);
  47.       _loc2_ = {x:0,y:0};
  48.       this.r.localToGlobal(_loc2_);
  49.       this.mask.lineTo(_loc2_.x,_loc2_.y);
  50.       _loc2_ = {x:0,y:0};
  51.       this.ro.localToGlobal(_loc2_);
  52.       var _loc4_ = Math.ceil(_loc2_.x);
  53.       this.mask.lineTo(_loc4_,_loc2_.y);
  54.       this.mask.lineTo(_loc4_,Stage.height);
  55.       this.mask.lineTo(_loc3_,Stage.height);
  56.       this.mask.endFill();
  57.    }
  58.    function initMask(lc, rc)
  59.    {
  60.       this.lo = lc;
  61.       this.ro = rc;
  62.       this.mask = _root.createEmptyMovieClip(this._name + "_mask",_root.getNextHighestDepth());
  63.       this.setMask(this.mask);
  64.    }
  65.    function endRace()
  66.    {
  67.       this.setMask(null);
  68.       this.mask.removeMovieClip();
  69.    }
  70.    function xaty(x, top)
  71.    {
  72.       if(Math.abs(x) > this.rad)
  73.       {
  74.          return undefined;
  75.       }
  76.       var _loc2_ = !top ? 1 : -1;
  77.       return this._y + _loc2_ * (this.rad * Math.cos(Math.asin((x - this._x) / this.rad)));
  78.    }
  79.    function setFilter(t)
  80.    {
  81.       t = t != undefined ? t : this.filters.length > 0;
  82.       if(t)
  83.       {
  84.          this.filters = null;
  85.       }
  86.       else
  87.       {
  88.          this.filters = [BackgroundMask.bf];
  89.       }
  90.    }
  91.    function flashingOff()
  92.    {
  93.       this.col.setTransform(BackgroundMask.flashOff);
  94.    }
  95.    function bright(t)
  96.    {
  97.       if(t)
  98.       {
  99.          this.col.setTransform(BackgroundMask.flashOn);
  100.       }
  101.       else
  102.       {
  103.          this.col.setTransform(BackgroundMask.flashOff);
  104.       }
  105.    }
  106. }
  107.